import { objDeepCopy,getDateString } from "@/assets/js/common.js";
import commonObject from "@/assets/js/xm.js";
let Controller = {
	created() {
		this.init();
	},
	mounted() {
		
	},
	methods: {
		init() {
			this.Model.barCode = this.$route.query.barCode; //id
			this.getDetailList(this,this.$route.query.barCode);
		},
		//获取 收料 详情列表
		getDetailList(that,barCode){
			var apiTest = this.apiTest;
			this.$ajax({
				method: 'get',
				// url: '/api/sale/saleGoodsInfo/getGoodsInfoByBarCode/'+barCode,
				url: apiTest+'/sale/saleGoodsInfo/getGoodsInfoByBarCode/'+barCode,
			}).then((res) => {
				var data = res.data;
				that.Model.tab1TableData = [];
				if (data.status == 200) {
					var result = data.result;
					var obj;
					/* var pagination = commonObject.paginationFunction(data.result);
					that.Model.paginationObject = objDeepCopy(pagination); */
					if(result){
						that.Model.tableData = objDeepCopy([result]);
					}
			
				} else {
					that.tips(that, 'warning', data.msg);
				}
			
			});
		},
		selectedHighlight(data) {
			// 如果选中则添加高亮样式
			if (this.Model.TableSelectData.indexOf(data.row) > -1) {
				return {
					"background-color": "#FEF6EE"
				};
				return {}
			}
		},
		back(){
			this.$router.push({
				path: 'ReturnOrderListDetail'
			})
		},
		warehousing(row) {
			this.Model.warehousingDialogStatus = row.status;
			this.Model.warehousingDialogFlag = true;
		},
		handleSelectionChange(val) {
			console.log(val);
			this.Model.addGiftsSelectData = val
		  
		},
		handleCurrentChange(val) {
			this.Model.pager.params.pageIndex = val;
		},
		handleSizeChange(val) {
			this.Model.pager.params.pageSize = val;
		},
		cardClick(color) {
			this.Model.cardSelected = color;
		},
		showChild(val) {
			this.Model.searchFromData = val;
		},
		toSearch(val) {
			console.log(val)
		},
		toClear(val) {
			this.Model.searchFromData = this.Model.defaultSearchFromData;
		},
		toExport(val) {
		  console.log(val);
		},
		onTabChange(val) {
			console.log(val, this.Model.activeTab)
			switch (val) {
				case 1:
					break;
				case 2:
					break;
				case 3:
					break;
			}
		},
		tips(that, type, message) {
			let duration;
			type == 'success' ? duration = 3000 : duration = 10000;
			that.$message({
				message: message,
				type: type,
				duration: duration
			});
		},
	},
	watch:{
		$route:{
		　　　handler(newValue, oldValue) {
				if (newValue.query.barCode) {
					this.getDetailList(this, newValue.query.barCode);
					this.Model.barCode = newValue.query.barCode;
				}
		　　　},
		　　　deep: true
		},
  	
	},
	filters:{
		objFilters:function(value){
			
		}
	}
}
export default Controller;
